import 'package:app/common/colors.dart';
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'document_view.dart';
import 'file_view.dart';
import 'package:get/get.dart';
class DocumentBottomTabBar extends StatefulWidget {
  const DocumentBottomTabBar({Key? key}) : super(key: key);

  @override
  State<DocumentBottomTabBar> createState() => _DocumentBottomTabBarState();
}

class _DocumentBottomTabBarState extends State<DocumentBottomTabBar> {

  int _selectedIndex = 0;

  final List<Widget>_pageList = [
    DocumentView(),
    DocumentView(),
  ];
  late PageController _pageController;


  _onItemSelected(int index){

    _pageController.jumpToPage(index);
    _selectedIndex = index;
    setState(() {

    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _pageController = PageController(initialPage: _selectedIndex);

  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,//Floating放在底部中间
      // floatingActionButton: GestureDetector(
      //   onTap:(){
      //     Get.bottomSheet(const BottomSheetPage(),);
      //   },
      //   child: Container(
      //     padding: EdgeInsets.only(top: 55),
      //     // height: 45,
      //     // width: 45,
      //
      //     // onPressed: (){
      //     //   Get.dialog(const BottomSheetPage(),transitionCurve: Curves.linear);
      //     // },
      //     child: Image.asset('images/round_add.png',width: 45,height: 45,),
      //
      //   ),
      // ),
      body: PageView(
        physics:  const NeverScrollableScrollPhysics(),
        controller: _pageController,
        children: _pageList,
      ),
      bottomNavigationBar: BrnBottomTabBar(
        fixedColor: AppColor.themeColor,
        currentIndex: _selectedIndex,
        onTap: _onItemSelected,
        badgeColor: Colors.red,
        items: [
          BrnBottomTabBarItem(icon:
          Image.asset('images/document_lately_cion.png',width: 25,height: 25,),
              activeIcon:Image.asset('images/document_lately_cion.png',width: 25,height: 25,
                color: AppColor.themeColor,) , title: Text('最近')),
          BrnBottomTabBarItem(icon: Image.asset('images/document-bottom_icon.png',
            width: 25,height: 25,),activeIcon:Image.asset('images/document-bottom_icon.png',
            width: 25,height: 25,color: AppColor.themeColor,) ,title: Text('文件')),
        ],
      ),
    );
  }
}
